extends Node2D

var heroDataArr:Array
var enemyDataArr:Array
var cellCountHorizontal
var cellCountVertical
var isHeroRound = false


func addHero(data):
	heroDataArr.append(data)
	

func addEnemy(data):
	enemyDataArr.append(data)
	

func setBattleFieldSize(horizontal, vertical):
	cellCountHorizontal = horizontal
	cellCountVertical = vertical
	

func findHeroActionNotFinish():
	var result = null
	for hero in heroDataArr:
		if not hero.battleActionFinish:
			result = hero
	return result


func findEnemyActionNotFinish():
	var result = null
	for enemy in enemyDataArr:
		if not enemy.battleActionFinish:
			result = enemy
	return result
	

func resetHeroActionFinishState():
	for hero in heroDataArr:
		hero.battleActionFinish = false
		

func resetEnemyActionFinishState():
	for enemy in enemyDataArr:
		enemy.battleActionFinish = false
		

func resetEntityActionFinishState():
	resetHeroActionFinishState()
	resetEnemyActionFinishState()


func getRandomHero():
	if heroDataArr.size() <= 0: return null
	
	var result = null
	var index = randi_range(0, heroDataArr.size() - 1)
	result = heroDataArr[index]
	
	return result


func herosCellPosArr():
	var result = []
	for hero in heroDataArr:
		result.append(hero.battlePos)
	return result
	

func enemiesCellPosArr():
	var result = []
	for enemy in enemyDataArr:
		result.append(enemy.battlePos)
	return result

	
